Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rfc4648

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfc4648

Encoding and decoding for base64, base32, base16, and friends

  • 1.5.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
increased by4.33%
Maintainers
1
Weekly downloads
 
Created

What is rfc4648?

The rfc4648 npm package provides utilities for encoding and decoding data in Base16, Base32, and Base64 formats, adhering to the specifications outlined in RFC 4648.

What are rfc4648's main functionalities?

Base16 Encoding

This feature allows you to encode data into Base16 (hexadecimal) format. The code sample demonstrates encoding a Uint8Array into a Base16 string.

const rfc4648 = require('rfc4648');
const data = new Uint8Array([72, 101, 108, 108, 111]);
const encoded = rfc4648.base16.stringify(data);
console.log(encoded); // Outputs: 48656C6C6F

Base16 Decoding

This feature allows you to decode Base16 (hexadecimal) strings back into their original data format. The code sample demonstrates decoding a Base16 string into a Uint8Array.

const rfc4648 = require('rfc4648');
const encoded = '48656C6C6F';
const decoded = rfc4648.base16.parse(encoded);
console.log(decoded); // Outputs: Uint8Array(5) [ 72, 101, 108, 108, 111 ]

Base32 Encoding

This feature allows you to encode data into Base32 format. The code sample demonstrates encoding a Uint8Array into a Base32 string.

const rfc4648 = require('rfc4648');
const data = new Uint8Array([72, 101, 108, 108, 111]);
const encoded = rfc4648.base32.stringify(data);
console.log(encoded); // Outputs: JBSWY3DP

Base32 Decoding

This feature allows you to decode Base32 strings back into their original data format. The code sample demonstrates decoding a Base32 string into a Uint8Array.

const rfc4648 = require('rfc4648');
const encoded = 'JBSWY3DP';
const decoded = rfc4648.base32.parse(encoded);
console.log(decoded); // Outputs: Uint8Array(5) [ 72, 101, 108, 108, 111 ]

Base64 Encoding

This feature allows you to encode data into Base64 format. The code sample demonstrates encoding a Uint8Array into a Base64 string.

const rfc4648 = require('rfc4648');
const data = new Uint8Array([72, 101, 108, 108, 111]);
const encoded = rfc4648.base64.stringify(data);
console.log(encoded); // Outputs: SGVsbG8=

Base64 Decoding

This feature allows you to decode Base64 strings back into their original data format. The code sample demonstrates decoding a Base64 string into a Uint8Array.

const rfc4648 = require('rfc4648');
const encoded = 'SGVsbG8=';
const decoded = rfc4648.base64.parse(encoded);
console.log(decoded); // Outputs: Uint8Array(5) [ 72, 101, 108, 108, 111 ]

Other packages similar to rfc4648

Keywords

FAQs

Package last updated on 10 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc